stage.set_axis(100)
stage.create_grid_overlay(10, "grey")
stage.set_background("soccerfield")
ballx = -80
bally = random.randint(-100,100)
t = codesters.Teacher()
params = t.get_parameters_for_function("Sprite")
try:
tval1 = params[0][0]
except:
tval1 = "DNE"
try:
tval2 = params[0][1]
except:
tval2 = "DNE"
try:
tval3 = params[0][2]
except:
tval3 = "DNE"
t1 = TestObjective()
t1.add_success(tval1 == '"soccerball"', "Great job!")
t1.add_failure(tval1 == "DNE", "Did you add a Sprite at Position command?")
t1.add_failure(tval1 != "DNE" and "ball" not in tval1, "Did you change the image label to 'soccerball'?")
t1.add_creative(tval1 != '"soccerball"' and "ball" in tval1 , "That sprite is cool too!")
t2 = TestObjective()
t2.add_success(tval2 == "ballx", "Great job!")
t2.add_failure(tval2 == "DNE", "Did you delete the x-coordinate?")
t2.add_failure(tval2 == "0", "Don't forget to change the x-coordinate to ballx!")
t2.add_failure(tval2 == "bally", "Did you reverse your x and y coordinates?")
t3 = TestObjective()
t3.add_success(tval3 == "bally", "Great job!")
t3.add_failure(tval3 == "DNE", "Did you delete the y-coordinate?")
t3.add_failure(tval3 == "0", "Don't forget to change the y-coordinate to bally!")
t3.add_failure(tval3 == "ballx", "Did you reverse your x and y coordinates?")
tester = TestManager()
tester.add_test_list([t1, t2, t3])
tester.run_tests()
tester.display_first_feedback()
-
Run Code
-
Activity Submitted!
Submit Work
-
Next Activity
-
Stop Running Code
-
Show Chart
-
Show Console
-
Reset Code Editor
-
Codesters How To (opens in a new tab)